#!/bin/bash

# CubeSLAM 健壮实时SLAM启动脚本
# 使用方法: ./start_robust_slam.sh [camera_id]

echo "=========================================="
echo "    CubeSLAM 健壮实时SLAM启动脚本"
echo "=========================================="

# 检查参数
CAMERA_ID=${1:-0}
echo "使用摄像头ID: $CAMERA_ID"

# 检查可执行文件是否存在
if [ ! -f "./Examples/bin/mono_realtime_robust" ]; then
    echo "错误: 找不到 mono_realtime_robust 可执行文件"
    echo "请先编译项目: cd build && make mono_realtime_robust"
    exit 1
fi

# 检查配置文件是否存在
if [ ! -f "./Examples/config/Realtime.yaml" ]; then
    echo "错误: 找不到配置文件 Realtime.yaml"
    exit 1
fi

# 检查词汇表文件是否存在
if [ ! -f "./Vocabulary/ORBvoc.txt" ]; then
    echo "错误: 找不到词汇表文件 ORBvoc.txt"
    exit 1
fi

echo "启动健壮实时SLAM..."
echo "按 Ctrl+C 优雅退出"
echo "=========================================="

# 启动健壮实时SLAM
./Examples/bin/mono_realtime_robust ./Vocabulary/ORBvoc.txt ./Examples/config/Realtime.yaml $CAMERA_ID

echo "健壮实时SLAM已退出"
